import java.util.ArrayList;
import java.util.List;

public class InorderTraversal {
    public int[] inorderTraversal (TreeNode root) {
        // write code here
        List<Integer> list = new ArrayList<>();
        inorderTraversalChild(root, list);
        return list.stream().mapToInt(Integer::intValue).toArray();
    }

    private void inorderTraversalChild(TreeNode root, List<Integer> list) {
        if (root == null) {
            return;
        }
        inorderTraversalChild(root.left, list);
        list.add(root.val);
        inorderTraversalChild(root.right, list);
    }
}
